package com.lh0811.forge.pserv.uacs.server.component.data_scope.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.lh0811.forge.pserv.uacs.server.component.data_scope.plugins.DataScopeInnerInterceptor;
import com.lh0811.forge.pserv.uacs.server.component.data_scope.provider.AbstractSysRuleValueProvider;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Slf4j
@Configuration
public class MybatisPlusConfig {

    @Resource
    public Map<String, AbstractSysRuleValueProvider> providerHashMap;

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 初始化Mybatis Plus拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new DataScopeInnerInterceptor(providerHashMap));
        return interceptor;
    }

}